package com.kerwin.springcloud.service.impl;

import cn.hutool.core.lang.UUID;
import com.kerwin.springcloud.service.IMessageProvider;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;

import javax.annotation.Resource;

@EnableBinding(Source.class)
public class MessageProviderImpl implements IMessageProvider {

    @Resource
    public MessageChannel output;
    @Override
    public String send() {
        String serial = UUID.randomUUID().toString();
        System.out.println("生产的序号：" + serial);
        output.send(MessageBuilder.withPayload(serial).build());
        return serial;
    }
}
